package com.subsequent.service.impl;

import com.subsequent.entity.DepartmentPharmacyConfig;
import com.subsequent.mapper.DepartmentPharmacyConfigMapper;
import com.subsequent.service.DepartmentPharmacyConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DepartmentPharmacyConfigServiceImpl implements DepartmentPharmacyConfigService {

    @Autowired
    private DepartmentPharmacyConfigMapper mapper;

    @Override
    public List<DepartmentPharmacyConfig> list(String name, String level, String pharmacy, String status, Integer parentId, Date startDate, Date endDate, int page, int pageSize) {
        int offset = (page - 1) * pageSize;
        return mapper.selectByCondition(name, level, pharmacy, status, parentId, startDate, endDate, offset, pageSize);
    }

    @Override
    public int count(String name, String level, String pharmacy, String status, Integer parentId, Date startDate, Date endDate) {
        return mapper.countByCondition(name, level, pharmacy, status, parentId, startDate, endDate);
    }

    @Override
    public void add(DepartmentPharmacyConfig config) {
        mapper.insert(config);
    }

    @Override
    public void update(DepartmentPharmacyConfig config) {
        mapper.updateById(config);
    }

    @Override
    public void delete(Integer id) {
        mapper.deleteById(id);
    }

    @Override
    public DepartmentPharmacyConfig getById(Integer id) {
        return mapper.selectById(id);
    }
}